<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData,subOnLoad, changeEditor,configSelectData,hasValue} from '../../../static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				exists:[],
				posCacheKey:'hr-zy-tpersonalCareerDevelop-title2-pos-cache'
			})
		},
		methods:{
			getPosRequire(posId){
				let _that = this
				_that.om.request(
					"tpqInfoFiles/getPosRequire",
					{
						posId:posId
					}
				).then(res=>{
					if(res.succeed&&res.value){
						_that.$refs.autoform.formdata.require1 = res.value
					}
				})
			},
			getPosTableStr(posId){
				let _that = this
				_that.om.request(
					"tpqInfoFiles/getPosTableStr",
					{
						posId:posId
					}
				).then(res=>{
					if(res.succeed&&res.value){
						_that.$refs.autoform.formdata.require2 = res.value
					}
				})
			}
		},
		onShow() {
			let _that = this
			if(_that.$refs.autoform){
				uni.getStorage({
					key:_that.posCacheKey,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.posId = d.id
							formdata.posName = d.posName
							formdata.instName = d.instName
							formdata.posGrade = d.careercatName
							formdata.posFeature = d.featureName
							_that.getPosRequire(d.id)
							_that.getPosTableStr(d.id)
							uni.removeStorage({
								key:_that.posCacheKey
							})
						}
					}
				})
			}
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
			if(e.configDataCacheKey){
				_that.exists = _that.datas.filter((e,i)=>{
					return (i!=_that.index)
				}).map(e=>e.posId).join(",")
				uni.getStorage({
					key: e.configDataCacheKey,
					success: function(res) {
						if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
							_that.autoformdata = res.data
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							let posList = new Array()
							posList.push(e.posId)
								changeEditor("title2","require1","disabled",true,_that.autoformdata)
								changeEditor("title2","require1","showClear",false,_that.autoformdata)
								changeEditor("title2","require1","prompt","请点击查看",_that.autoformdata)
								changeEditor("title2","require2","disabled",true,_that.autoformdata)
								changeEditor("title2","require2","showClear",false,_that.autoformdata)
								changeEditor("title2","require2","prompt","请点击查看",_that.autoformdata)
								changeEditor("title2","posId",{
									link:"../../public/pageSearch/pageSearch",
									"linkParam":{
										other:JSON.stringify({
											"posIdList[]":posList,
											"noList[]":_that.exists
										}),
										namefield:"posName",
										initload:true,
										method:"post",
										searchfield:"q",
										url:"posPromotionChannelList/getProPosList",
										cachename:_that.posCacheKey,
										placeholder:'请选择岗位'
									}
								},null,_that.autoformdata)
							}
						}
					})
				}
			})
		}
	}
</script>

<style>
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
